﻿
@{
    ViewBag.Title = "住院费用分类清单";
    Layout = "~/Views/Shared/_Form.cshtml";
    var reportUrl = Newtouch.Core.Common.Utils.ConfigurationHelper.GetAppConfigValue("ReportUrl");
    var reportSystemCode = Newtouch.Core.Common.Utils.ConfigurationHelper.GetAppConfigValue("ReportSystemCode");
}

<div class="rows">
    <div class="panel panel-default">
        <table class="form">
            <tr>
                <th class="formTitle">住院号：</th>
                <td class="formValue">
                    <input id="zyh" name="zyh" type="text" autocomplete="off" class="form-control" />
                </td>
                <th class="formTitle">开始日期：</th>
                <td class="formValue">
                    <input id="ksrq" type="text" class="form-control input-wdatepicker formClearIgnore" style="width:90px"
                           onclick="WdatePicker({ dateFmt: 'yyyy-MM-dd' })"
                           onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd', onpicked: function () { refReport(); } })"
                           value="@DateTime.Now.ToString("yyyy-MM-01")" />
                </td>
                <th class="formTitle">结束日期：</th>
                <td class="formValue">
                    <input id="jsrq" type="text" class="form-control input-wdatepicker formClearIgnore" style="width:90px"
                           onclick="WdatePicker({ dateFmt: 'yyyy-MM-dd' })"
                           onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd', onpicked: function () { refReport(); } })"
                           value="@DateTime.Now.ToString("yyyy-MM-dd")" />
                </td>
                <th class="formTitle"></th>
                <td class="formValue" style="padding-left:20px;">
                    <input type="button" id="btn_search" onclick="submit();" class="btn btn-primary btn-md" value="查询" style="width:55px" />
                </td>
                <th></th>
                <td></td>
                <th></th>
                <td></td>
            </tr>
        </table>
    </div>
</div>


<div class="ui-layout" id="layout" style="height:100%;width:100%;">
    <iframe class="ui-layout-center" style="width:100%;" id="iframerightiframerightiframerightttt" name="iframerightiframerightiframerightttt"
            scrolling="auto" allowtransparency="true" frameborder="0"></iframe>
</div>




<script type="text/javascript">
    var isHospAdministrator = '@(ViewBag.IsHospAdministrator)';
    var curUserCode = '@(ViewBag.CurUserCode)';
    var OrgId = '@(ViewBag.OrgId)';
    var reportServerHOST = '@(ViewBag.ReportServerHOST)';

    //治疗项目选择浮层绑定
    $('#zyh').newtouchBatchFloatingSelector({
        width: 500,
        height: 200,
        caption: "选择患者",
        clickautotrigger: true,
        url: "/ReportManage/Report/GetInpatientcryrq",
        ajaxparameters: function ($thisinput) {
            var keyword = $thisinput.val().trim();
            var zyh = $("#zyh").val();
            return "zyh=" + zyh;
        },
        itemdbclickhandler: function ($thistr, $thisinput) {
            if (!!$thistr.attr('data-zyh')) {
                //if ($thistr.attr('data-ryrq') !== "" && $thistr.attr('data-ryrq') !== undefined && $thistr.attr('data-ryrq') !== null) {
                //    $('#ksrq').val($.getDate({ date: $thistr.attr('data-ryrq') }));
                //}
                //if ($thistr.attr('data-cyrq') !== "" && $thistr.attr('data-cyrq') !== undefined && $thistr.attr('data-cyrq') !== null) {
                //    $('#jsrq').val($.getDate({ date: $thistr.attr('data-cyrq') }));
                //} else {
                //    $('#jsrq').val($.getDate());
                //}
                $('#zyh').val($thistr.attr('data-zyh'));
                //submit();
            }
        },
        colModel: [
            { label: '住院号', name: 'zyh', width: 100 },
            { label: 'cyrq', name: 'cyrq', hidden: true },
            { label: 'ryrq', name: 'ryrq', hidden: true },
            { label: '在院标志', name: 'zybz', width: 100, align: 'left' },
            { label: '姓名', name: 'xm', width: 120, align: 'left' },
            { label: '出生年月', name: 'csny', hidden: true, width: 100, align: 'left' },
            {
                label: '性别', name: 'xb', width: 50, align: 'left', formatter: function (cellvalue) {
                    return $.getGender(cellvalue);
                }
            },
            {
                label: '年龄', name: 'nlshow', width: 50, align: 'left', formatter: function (cellvalue, a, b) {
                    return getAgeFromBirthTime({ begin: b.csny }).text;
                }
            }
        ]
    });

    function submit() {

        if ($('#zyh').val().length == 0) {
            $.modalAlert("缺少住院号", "error");
            return;
        }
        if ($('#ksrq').val().length == 0 || $('#jsrq').val().length == 0) {
            $.modalAlert("请选择时间范围", "error");
            return;
        }

        //同步费用
        //$.ajax({
        //    url: "/ReportManage/Report/SynInpatientDayFee",
        //    data: { zyh: $('#zyh').val() },
        //    dataType: "json",
        //    type: "POST",
        //    async: false,
        //    success: function (data) {
        //    }
        //})

        var url = '@Html.Raw(reportUrl)' + "?tempCode=1219" + "&systemCode=" + '@reportSystemCode';
		url += " &zyh=" + $('#zyh').val();
		url += " &orgId=" + OrgId;
		url += " &kssj=" + $('#ksrq').val();
		url += " &jssj=" +$('#jsrq').val();
        
        setTimeout("$.loading(true, '正在请求报表页面...');", 10);
        $("#iframerightiframerightiframerightttt").attr('src', url);
    }

    $("#iframerightiframerightiframerightttt").load(function () {
        $.loading(false);
    });

    $(function () {
        var h = $(window).height() - 55
        $('#layout iframe').css('height', h);

    });

    //刷新列表
    function refReport() {
        $("#btn_search").trigger('click');
    }

    function getUrl() {
        var srcUrl2 = "/ReportServer/Pages/ReportViewer.aspx?%2fHIS.Report.1%2fChongqing住院费用分类清单v2&rs:Command=Render&rc:Stylesheet=MyStyleSheet&orgId=" + OrgId + "&zyh=" + $('#zyh').val() + "&kssj=" + $('#ksrq').val() + "&jssj=" + $('#jsrq').val() + "&doctor=" + curUserCode;
        if (srcUrl2.StartWith('/')) {
            srcUrl2 = srcUrl2.substr(1);
        }
        srcUrl = srcUrl2;
        srcUrl = reportServerHOST + srcUrl;
        console.info(srcUrl);


        return srcUrl;
    }

</script>
